<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>$msg.get("title")</title>
  <link rel="stylesheet" type="text/css" href="../stylesheet.css">
</head>
<body onload="setTitle()">
<script type="text/javascript">
function setTitle(){
  parent.document.title="$table.tableName";
}
</script>

<h2
  #if($table.linkedTable)
    class="imported"
  #end
>
  ${util.escapeHTML2($table.tableName)}
  #if(!$util.isEmpty($table.logicalName))
    (${util.escapeHTML2($table.logicalName)})
  #end
</h2>

#if(!$util.isEmpty($table.description))
  <p>$util.escapeHTML2($table.description)</p>
#end
#if($table.linkedTable)
  <p class="note">$msg.get("note.importedTable")</p>
#end

<table width="100%" border="1" cellpadding="3" cellspacing="0" >
  <tr class="TableHeadingColor">
    <th width="3%">$msg.get("column.rownum")</th>
    <th width="14%">$msg.get("column.logicalName")</th>
    <th width="14%">$msg.get("column.physicalName")</th>
    <th width="10%">$msg.get("column.type")</th>
    <th width="3%">$msg.get("column.null")</th>
    <th width="7%">$msg.get("column.defaultValue")</th>
    <th width="30%">$msg.get("column.description")</th>
  </tr>
  #foreach($column in $table.columns)
  <tr>
    <td align="right" nowrap>
      #if($column.primaryKey == true)
        <img src="../images/primarykey.gif">
      #end
      $velocityCount
    </td>
    <td><strong>$util.escapeHTML2($column.logicalName)</strong></td>
    <td><strong><code>$util.escapeHTML2($column.columnName)</code></strong></td>
    <td><code>$util.escapeHTML2($column.columnType.name)#if($column.columnType.supportSize() && $column.size.length() > 0)($column.size)#end</code></td>
    <td align="center">
    #if($column.notNull == true)
      N
    #else
      Y
    #end
    </td>
    <td>$util.escapeHTML2($column.defaultValue)</td>
    <td>
    #if($column.dommain)
      ${msg.get("column.description.dommain")}: ${util.escapeHTML($column.dommain.name)}<br>
    #end
    #if($column.autoIncrement == true)
      AUTO INCREMENT<br>
    #end
    #if($column.description!="")
      $util.escapeHTML($column.description)
    #elseif($column.autoIncrement == false && !$column.dommain)
      &nbsp;
    #end
    </td>
  </tr>
  #end
</table>

#if(!$table.modelSourceConnections.empty)
  <br>
  <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr class="TableHeadingColor">
      <td><strong>$msg.get("foreignKeys")</strong></td>
    </tr>
  </table>
  #foreach($conn in $table.modelSourceConnections)
    #if($velocityCount != 1)
    <hr>
    #end
    <h3>$conn.foreignKeyName</h3>
    <table border="1" cellpadding="3" cellspacing="0">
      <tr><th>字  段</th><th>关联字段</th></tr>
      #foreach($mapping in $conn.mapping)
      <tr>
        <td><code>$mapping.refer.columnName</code></td>
        <td><code><a href="${conn.target.tableName}.html">${util.escapeHTML($conn.target.tableName)}.${util.escapeHTML($mapping.target.columnName)}</a></code></td>
      </tr>
      #end
    </table>
  #end
#end

#if(!$util.isEmpty($table.indices))
  <br>
  <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr class="TableHeadingColor">
      <td><strong>$msg.get("indices")</strong></td>
    </tr>
  </table>
  
  #foreach($index in $table.indices)
    #if($velocityCount != 1)
    <hr>
    #end
    <h3>$index.indexName ($index.indexType.name)</h3>
    <dl>
      <dt><strong>字  段:</strong></dt>
      <dd>
        #foreach($indexColumn in $index.columns)
          <code>$indexColumn</code><br>
        #end
      </dd>
    </dl>
  #end
  
#end

#if(!$table.modelTargetConnections.empty)
  <br>
  <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr class="TableHeadingColor">
      <td><strong>$msg.get("referencedTables")</strong></td>
    </tr>
  </table>
  <br>
  <table border="1" cellpadding="3" cellspacing="0">
    <tr><th>表  名</th><th>字  段</th></tr>
    #foreach($conn in $table.modelTargetConnections)
      #foreach($mapping in $conn.mapping)
        <tr>
          <td><code><a href="${conn.source.tableName}.html">${conn.source.tableName}.${mapping.refer.columnName}</a></code></td>
          <td>
            <code>$mapping.target.columnName</code><br>
          </td>
        </tr>
      #end
    #end
  </table>
#end

</body>
</html>